/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    FanZhiwen
 * 创建时间:    2023-10-09
 */
package org.jeecg.modules.flow.callback.inbound.task;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.business.third.service.IEmsOrDmsDeliveryOperateService;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTask;
import org.jeecg.modules.business.warehouse.entity.vo.WmsInReceiptTaskPage;
import org.jeecg.modules.business.warehouse.service.IWmsInReceiptTaskService;
import org.jeecg.modules.flow.callback.enums.DocumentStatusEnum;
import org.jeecg.modules.flow.sys.common.BaseCustomBeanRun;
import org.jeecg.modules.flow.sys.entity.dto.BaseFlowDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 入库任务配送bean
 *
 * @author FanZhiwen
 * @version 1.0.0
 * @since 2023-10-09
 */
@Component
@Slf4j
@Deprecated
public class WmsInReceiptTaskDeliveryBeforeBean<T> extends BaseCustomBeanRun<T> {
    @Autowired
    private IEmsOrDmsDeliveryOperateService emsOrDmsDeliveryOperateService;
    @Autowired
    private IWmsInReceiptTaskService iWmsInReceiptTaskService;
    @Override
    public void actureRun() {
        log.info("配送任务执行了");
        BaseFlowDto baseFlowDto = this.getBaseFlowDto();
        // 获取请求参数
        baseFlowDto.translateClass(WmsInReceiptTaskPage.class);
        WmsInReceiptTaskPage jsonVO = (WmsInReceiptTaskPage) baseFlowDto.getData();
        String taskId = jsonVO.getId();
        //todo: 调用配送接口
//        emsOrDmsDeliveryOperateService.delivery();
        //修改任务状态为执行中
        WmsInReceiptTask task = iWmsInReceiptTaskService.getById(taskId);
        task.setDocumentStatus(DocumentStatusEnum.PROCESS.getCode());
        iWmsInReceiptTaskService.updateById(task);
        //驱动自动入库流程
        baseFlowDto.setResult(Result.OK());
        // id是保存业务记录的id。用于生成业务流程信息记录
        baseFlowDto.setInfoId(taskId);
    }
}
